package ui.frame.dialog.panel;

import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import static constants.GTextbookConstants.*;

public class TextAreaPanel extends JPanel{

	public TextAreaPanel(int whichArea, String englishName, String chineseName, int language, Dimension textAreaDimension){
		//construct a text area
		textArea = new CompletableJTextArea(whichArea);
		//put the text area in a scroll pane
		textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);       
		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setPreferredSize(textAreaDimension);
		
		//set the look of components
        if(language == English){
        	label = new JLabel(englishName,SwingConstants.RIGHT);
        	label.setFont(Label_English_Font);
        	label.setPreferredSize(Label_English_Dimension);
        	textArea.setFont(Input_English_Font);
        }
        if(language == Chinese){
        	label = new JLabel(chineseName,SwingConstants.LEFT);
        	label.setFont(Label_Chinese_Font);
        	label.setPreferredSize(Label_Chinese_Dimension);
        	textArea.setFont(Input_Chinese_Font);
        }
        
        add(label);
        add(scrollPane);

	}
	
	public TextAreaPanel(String englishName, String chineseName, int language, Dimension textAreaDimension){
		//construct a text area
		textArea = new JTextArea();
		
		//put the text area in a scroll pane
		textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);       
		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setPreferredSize(textAreaDimension);
		
		//set the look of components
        if(language == English){
        	label = new JLabel(englishName,SwingConstants.RIGHT);
        	label.setFont(Label_English_Font);
        	label.setPreferredSize(Label_English_Dimension);
        	textArea.setFont(Input_English_Font);
        }
        if(language == Chinese){
        	label = new JLabel(chineseName,SwingConstants.LEFT);
        	label.setFont(Label_Chinese_Font);
        	label.setPreferredSize(Label_Chinese_Dimension);
        	textArea.setFont(Input_Chinese_Font);
        }
        
        add(label);
        add(scrollPane);

	}
	
	public JLabel getLabel() {
		return label;
	}
	public void setLabel(JLabel label) {
		this.label = label;
	}
	public JTextArea getTextArea() {
		return textArea;
	}
	public void setTextArea(JTextArea textArea) {
		this.textArea = textArea;
	}
	
	private JLabel label;
	private JTextArea textArea;
 
	
}
